package com.ting.test.algorithms.贪心算法.最大项目收益;

import java.util.Comparator;

public class Program {
    int cost;
    int profits;

    public Program(int cost, int profits) {
        this.cost = cost;
        this.profits = profits;
    }

    public int getCost() {
        return cost;
    }

    public void setCost(int cost) {
        this.cost = cost;
    }

    public int getProfits() {
        return profits;
    }

    public void setProfits(int profits) {
        this.profits = profits;
    }
}

/**
 * 按花费从小到大
 */
class MinComparator implements Comparator<Program>{

    @Override
    public int compare(Program o1, Program o2) {
        return o1.cost-o2.cost;
    }
}

/**
 * 按收益从大到小
 */
class MaxComparator implements Comparator<Program>{

    @Override
    public int compare(Program o1, Program o2) {
        return o2.profits-o1.profits;
    }
}